package com.acoffee.service.Impl;

import com.acoffee.mapper.UserMapper;
import com.acoffee.pojo.User;
import com.acoffee.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @author acoffee
 * @create 2021-11-14 16:13
 */
public class UserServiceImpl implements UserService {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
    UserMapper userMapper = applicationContext.getBean("userMapper", UserMapper.class);


    @Override
    public List<User> queryAll() {
        List<User> list = userMapper.queryAll();
        return list;
    }

    @Override
    public User queryById(int id) {
        User user = userMapper.queryById(1);
        return user;
    }

    @Override
    public void deleteUser(int id) {
        userMapper.deleteUser(id);
    }

    @Override
    public void addUser(User user) {
        userMapper.addUser(user);
    }

    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
}
